﻿using System.ServiceModel;
using Common.Builders;
using Common.Builders.Interfaces;
using Common.Cryptography;
using DataAccess.Accessors;
using DataAccess.Accessors.Interfaces;
using DataAccess.Converters;
using DataAccess.Interfaces;
using DataAccess.Repository;
using DataAccess.Repository.Interfaces;
using DataAccess.Services;
using Infrastructure.Gateways.Facebook;
using Infrastructure.Gateways.Vk;
using Infrastructure.Interfaces;
using Infrastructure.Logging;
using Infrastructure.Services;
using Infrastructure.Web;
using Ninject.Extensions.Wcf;
using Ninject.Modules;
using Ninject.Syntax;

namespace NinjectCore
{
    public class CoreNinjectModule : NinjectModule
    {
        public override void Load()
        {
            Bind<IResolutionRoot>().ToConstant(Kernel);
            Bind<ServiceHost>().To<NinjectServiceHost>();

            Bind<IDataEncryptor>().To<SymmetricDataEncryptor>();
            Bind<IUserEncryptor>().To<UserEncryptor>();
            /*Providers*/
            Bind<IUserAuthenticationProvider>().To<UserAuthenticationProvider>();
            Bind<IUserRegistrationProvider>().To<UserRegistrationProvider>();
            Bind<INHibernateSessionProvider>().To<NHibernateSessionProvider>();
            Bind<ISecurityKeyGenerator>().To<SecurityKeyGenerator>();

            /*Repository*/
            Bind<IUserRepository>().To<UserRepository>();
            Bind<IUserAccountRepository>().To<UserAccountRepository>();
            Bind<ISecurityKeyRepository>().To<SecurityKeyRepository>();
            Bind<ISocialNetworkRepository>().To<SocialNetworkRepository>();

            /*Converters*/
            Bind<IUserEntityConverter>().To<UserEntityConverter>();
            Bind<IUserAccountEntityConverter>().To<UserAccountEntityConverter>();
            Bind<ISocialNetworkConverter>().To<SocialNetworkConverter>();

            /*Accessors*/
            Bind<IDataAccessor>().To<DataAccessor>();
            Bind<IUserAccessor>().To<UserAccessor>();
            Bind<IUserAccountAccessor>().To<UserAccountAccessor>();
            Bind<ISocialNetworkAccessor>().To<SocialNetworkAccessor>();
            Bind<ISecurityKeyAccessor>().To<SecurityKeyAccessor>();

            /*Builders*/
            Bind<IUserBuilder>().To<UserBuilder>();
            Bind<IUserAccountBuilder>().To<UserAccountBuilder>();

            Bind<IResponseDetailsService>().To<ResponseDetailsService>();
            Bind<IUserAccountValidator>().To<UserAccountValidator>();

            Bind<ILoggingService>().To<LoggingService>();
            Bind<IFacebookLoginGateway>().To<FacebookLoginGateway>();
            Bind<IConfigurationManager>().To<CustomConfigurationManager>();
            Bind<IGatewayDetailsService>().To<GatewayDetailsService>();
            Bind<IWebRequest>().To<WebRequest>();
            Bind<IJsonSerializer>().To<JsonSerializer>();
            Bind<IFacebookGateway>().To<FacebookGateway>();

            Bind<IVkLoginGateway>().To<VkLoginGateway>();
        }
    }
}
